package com.taotao.sso.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.mapper.TbUserMapper;
import com.taotao.pojo.TbUser;
import com.taotao.pojo.TbUserExample;
import com.taotao.pojo.TbUserExample.Criteria;
import com.taotao.sso.service.UserRegisterServcie;
@Service
public class UserRegisterServiceImpl implements UserRegisterServcie {
	@Autowired
	private TbUserMapper userMapper;
	@Override
	public TaotaoResult getUserInfo(String param, int type) {
		//判断用户信息是否已经存在
		TbUserExample example=new TbUserExample();
		Criteria criteria = example.createCriteria();
		//判断1是用户名2是密码3是邮箱
		if(type==1){
			criteria.andUsernameEqualTo(param);
		}else if(type==2){
			criteria.andPasswordEqualTo(param);
		}else {
			criteria.andEmailEqualTo(param);
		}
		List<TbUser> list=userMapper.selectByExample(example);
		if(list==null||list.size()==0){
			return TaotaoResult.ok(true);
		}
		return TaotaoResult.ok(false);
	}

	@Override
	public TaotaoResult createUser(TbUser user) {
		// TODO Auto-generated method stub
		return null;
	}


}
